package com.online.service;

import com.online.dao.OptionMapper;
import com.online.entity.Option;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OptionServiceImpl implements OptionService {

    @Autowired
    OptionMapper optionMapper;

    @Override
    public List<Option> showOptionByKnowledge(String knowledge) {
        return optionMapper.selectOptionByKnowledge(knowledge);
    }

    @Override
    public Option showOptionById(Integer optionId) {
        return optionMapper.selectOptionById(optionId);
    }

    @Override
    public int addOption(Option option) {
        return optionMapper.addOption(option);
    }

    @Override
    public List<Option> showOptionKnowledge() {
        return optionMapper.selectKnowledge();
    }

    @Override
    public int countOption(String knowledge) {
        return optionMapper.countOptionNumber(knowledge);
    }

    @Override
    public List<Option> showByRandom(int optionsNumber, String optionsKnowledge) {
        return optionMapper.selectRandom(optionsNumber,optionsKnowledge);
    }

    @Override
    public List<Option> showOption() {
        return optionMapper.showOptions();
    }

    @Override
    public int deleteOption(Integer optionId) {
        return optionMapper.deleteRecord(optionId);
    }
}
